package com.tanhua.server.config;

import com.tanhua.server.interceptor.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 这是web拦截器配置类 打上注解 configuration
 * 实现WebMvcConfigurer
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    //注入token拦截器对象
    @Autowired
    private TokenInterceptor tokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/**") // 拦截所有的请求
                // 过滤的请求
                .excludePathPatterns("/user/login","/user/loginVerification");
    }
}
